<template>
    <div>
        <Header :left="true" leftText="返回" title="质量辅助决策" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-model="currentBatch" label="当前批次"
            placeholder="当前批次" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-model="libStrict" label="实验室加严"
            placeholder="实验室加严" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-model="appearanceStrict"
            label="外观加严" placeholder="外观加严" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-model="allErrorNum" label="总异常"
            placeholder="总异常" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-model="apErrorNum" label="外观检验异常"
            placeholder="外观检验异常" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-model="libErrorNum" label="实验室检验异常"
            placeholder="实验室检验异常" />

        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">本班次异常统计(当前日期所在班次)</NoticeBar>
        <div class="selectdTextScroll">
            <v-table is-horizontal-resize style="width: 100%" :show-vertical-border="true" :columns="columnBBC"
                :table-data="dataBBC" row-hover-color="#eee" row-click-color="#edf7ff"></v-table>
            <van-pagination width="this.screenWidth" class="pagination" force-ellipses v-model="bbcPage.pageNum"
                :total-items="bbcPage.total" @change="bbc_page" :items-per-page="bbcPage.pageSize" />
        </div>

        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">外观检检记录</NoticeBar>

        <div class="selectdTextScroll">
            <v-table is-horizontal-resize style="width: 100%" :show-vertical-border="true" :columns="columnSYS"
                :table-data="dataSYS" :row-click="rowClick" row-hover-color="#eee" row-click-color="#edf7ff"></v-table>
            <van-pagination width="this.screenWidth" class="pagination" force-ellipses v-model="sysPage.pageNum"
                :total-items="sysPage.total" @change="sys_page" :items-per-page="sysPage.pageSize" />
        </div>

        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">实验室质检记录
        </NoticeBar>

        <div class="selectdTextScroll">
            <v-table is-horizontal-resize style="width: 100%" :show-vertical-border="true" :columns="columnQC"
                :table-data="dataQC" :row-click="checkSYS" row-hover-color="#eee" row-click-color="#edf7ff"></v-table>
            <van-pagination width="this.screenWidth" class="pagination" force-ellipses v-model="pageQC.pageNum"
                :total-items="pageQC.total" @change="qc_page" :items-per-page="pageQC.pageSize" />
        </div>
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">数据分析</NoticeBar>

        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-model="item.StatID" label="统计代码选择"
            placeholder="指标代码选择" @click="showPickerPStatID = true" />
        <van-popup v-model="showPickerPStatID" position="bottom">
            <van-picker show-toolbar :columns="statColumn2" @confirm="onConfirmStatID" @cancel="showPickerPStatID = false">
                <template #option="option">
                    <div style="display: flex; flex-direction: column; align-items: center">
                        <div>{{ option.Pshow }}</div>
                    </div>
                </template>
                <template #title>
                    <van-field v-model="searchKey2" placeholder="请输入搜索内容" clearable />
                </template>
            </van-picker>
        </van-popup>
        <br />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-if="dataDA.length > 0"
            v-model="dataDA[0].StatID" label="指标代码" placeholder="指标代码" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-if="dataDA.length > 0"
            v-model="dataDA[0].StatName" label="质检统计项" placeholder="质检统计项" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-if="dataDA.length > 0"
            v-model="dataDA[0].StandardValue" label="标准值" placeholder="标准值" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-if="dataDA.length > 0"
            v-model="dataDA[0].LowValue" label="标准下限值" placeholder="标准下限值" />
        <van-field readonly class="formstyle" style="font-weight: bold" name="picker" v-if="dataDA.length > 0"
            v-model="dataDA[0].TopValue" label="标准上限值" placeholder="标准上限值" />
        <!-- <van-field  readonly class="formstyle" style="font-weight: bold" name="picker" v-model="dataDA[0].AverageValue"
                label="平均值" placeholder="平均值"  /> -->
        <div class="selectdTextScroll">
            <v-table is-horizontal-resize style="width: 100%" :show-vertical-border="true" :row-click="rowClick02"
                :columns="columnDA" :table-data="dataDA" row-hover-color="#eee" row-click-color="#edf7ff"></v-table>
            <van-pagination width="this.screenWidth" class="pagination" force-ellipses v-model="pageDA.pageNum"
                :total-items="pageDA.total" @change="da_page" :items-per-page="pageDA.pageSize" />
        </div>
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">检验指标的平均值</NoticeBar>
        <div ref="avg" id="avg" style="width: 100%; height: 250px"></div>
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">检验指标的标准差</NoticeBar>
        <div ref="sd" id="sd" style="width: 100%; height: 250px"></div>
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">一周温湿度曲线</NoticeBar>
        <div ref="wsd" id="wsd" style="width: 100%; height: 250px"></div>
        <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
            left-icon="description">一周生产周期秒变化</NoticeBar>
        <div ref="mbh" id="mbh" style="width: 100%; height: 250px"></div>
    </div>
</template>

<script>
import {
    Col,
    Row,
    Form,
    Cell,
    Icon,
    Field,
    NumberKeyboard,
    Image as VanImage,
    Picker,
    popup,
    SubmitBar,
    Button,
    Loading,
    Overlay,
    Dialog,
    Pagination,
    Toast,
    NoticeBar,
    Tag,
    DatetimePicker,
    ImagePreview,
    CellGroup,
    Uploader,
    Cascader,
    Calendar,
    RadioGroup,
    Radio,
    Divider,
    Stepper,
    AddressList,
    Checkbox,
    CheckboxGroup,
} from "vant";

import apicloud from '@/libs/apicloud'
import { VTable } from "vue-easytable";
import "vue-easytable/libs/themes-base/index.css";
import { _httpClient as _httpClientApisie } from "@/libs/apisie";
import { _httpClient as _httpClientApi } from "@/libs/api";
import { getToken, getBaseApiFrefix } from "@/libs/auth";
import Header from "@/components/header.vue";
import { storage } from "@/libs/utils";
import * as echarts from "echarts";
import dataTool from "echarts/extension/dataTool";
Vue.use(Form);
Vue.use(Field);
Vue.use(Overlay);
Vue.use(Loading);
Vue.use(Picker);
Vue.use(popup);
Vue.use(SubmitBar);
Vue.use(VanImage);
Vue.use(DatetimePicker);
Vue.use(Pagination);
Vue.use(Cascader);
Vue.use(Calendar);
Vue.use(Cell);
Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(Divider);
Vue.use(Stepper);
Vue.use(Button);
Vue.use(AddressList);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Col);
Vue.use(Row);
export default {
    name: 'qualityAssistanceShow',
    components: {
        Form,
        Row,
        Col,
        Button,
        Header,
        Form,
        Cell,
        Icon,
        Field,
        NumberKeyboard,
        Dialog,
        Toast,
        NoticeBar,
        Row,
        Tag,
        popup,
        DatetimePicker,
        ImagePreview,
        CellGroup,
        Uploader,
        Col,
        Calendar,
        Cascader,
        Picker,
        RadioGroup,
        Radio,
        Divider,
        Stepper,
        VTable,
        AddressList,
        Checkbox,
        CheckboxGroup,
    },
    data() {
        return {
            showPickerPStatID: false,
            searchKey2: "",
            statColumn: [],
            statColumn2: [],

            screenWidth: 100,
            item: null,
            currentBatch: "",
            libStrict: "",
            appearanceStrict: "",
            allErrorNum: 0,
            apErrorNum: 0,
            libErrorNum: 0,

            columnSYS: [
                {
                    field: "BatchID",
                    title: "批次号",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                }
            ],
            dataSYS: [],
            sysPage: {
                pageNum: 1,
                pageSize: 5,
                total: 0,
            },
            columnDA: [
                //点检表格列头
                {
                    field: "BatchID",
                    title: "批次号",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "AverageValue",
                    title: "平均值",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "StandardGap",
                    title: "标准差",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "ExceedTopCount",
                    title: "超上限个数",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },

                {
                    field: "ExceedLowCount",
                    title: "超下限个数",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "ConfidenceInterval",
                    title: "置信区间",
                    width: 270,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },

            ],
            dataDA: [],
            pageDA: {
                pageNum: 1,
                pageSize: 5,
                total: 0,
            },

            columnQC: [
                {
                    field: "BatchID",
                    title: "生产批次",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "PLineID",
                    title: "生产线代码",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "POrderID",
                    title: "订单号码",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "MaterialID",
                    title: "产品代码",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "MaterialName",
                    title: "产品名称",
                    width: 300,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "SheetName",
                    title: "检验记录单",
                    width: 600,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "ProductionDate",
                    title: "生产日期",
                    width: 200,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "CheckTypeName",
                    title: "检验类型名称",
                    width: 400,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "CheckTypeID",
                    title: "检验类型",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "WorkshopID",
                    title: "生产车间",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "CheckStationID",
                    title: "检验工作站",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "TeamID",
                    title: "班组",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "PShiftID",
                    title: "班次",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "FactoryID",
                    title: "工厂代码",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
            ],
            dataQC: [],
            pageQC: {
                pageNum: 1,
                pageSize: 5,
                total: 0,
            },
            columnBBC: [
                {
                    field: "EventType",
                    title: "异常类型",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "EventDatetime",
                    title: "事件发生时间",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "processStatus",
                    title: "处理状态",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "EventDescription",
                    title: "事件描述",
                    width: 800,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "MessageContent",
                    title: "消息内容(JSON格式)",
                    width: 1500,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "MsgContentTypeID",
                    title: "消息内容分类",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "PLineID",
                    title: "生产线代码",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
                {
                    field: "PLineID",
                    title: "设备代码",
                    width: 170,
                    titleAlign: "center",
                    columnAlign: "center",
                    isResize: true,
                    titleCellClassName: "title-cell-class-name-test",
                },
            ],
            dataBBC: [],
            bbcPage: {
                pageNum: 1,
                pageSize: 5,
                total: 0,
            },
            //箱线图
            RecordValueList: []

        };
    },
    watch: {
        'searchKey2': {
            handler(newVal) {
                // alert("----")
                let key = String(newVal);
                //alert(key);
                key = key.replace(/\s*/g, "");
                const reg = new RegExp(key, "ig");
                /* 进行筛选，将筛选后的数据放入新的数组中，‘name’键可根据需要搜索的key进行调整 */
                this.statColumn2 = this.statColumn.filter(item => item.Pshow.match(reg) != null);
                // alert(JSON.stringify(this.statColumn2));
            },
            deep: true,
            immediate: true,
        },
    },
    created() {
        let oldHight = api.winWidth
        this.screenWidth = oldHight
        this.item = this.$ac.pageParam.item
        this.getStatID()



    },
    mounted() {

        this.getQualityDecision()
        this.getQualityAppearanceCheck()
        this.getQualityCheckRecord()
        this.getGetCurrentShiftTreeTypeMsg()
        // this.getQualityDecisionAnalysis()
        // this.initAvgFigure()

    },


    methods: {
        async checkSYS(rowIndex, columnName, rowData) {

            let id = this.dataQC[rowIndex].Id

            api.openWin({
                name: 'viewlaboratorytest2',
                url: './equipmentsj-viewlaboratorytest2.html',
                pageParam: {
                    id: id
                }
            });

        },
        async getStatID() {

            let _this = this;
            try {
                let res = await _httpClientApisie.get(
                    _httpClientApisie.getApiPrefix() + "/QualityStatisticItem/GetList"
                );
                if (res.HttpCode === "200") {
                    let teamMap = res.Data.map((item) => ({
                        StatID: item.StatID,
                        StatName: item.StatName,
                        Pshow: item.StatID + " " + item.StatName
                    }));
                    _this.statColumn = teamMap;
                    _this.statColumn2 = teamMap;
                }
            } catch (e) {
                Toast.fail(JSON.stringify(e));
            }
        },
        onConfirmStatID(value, index) {
            this.item.StatID = this.statColumn2[index].StatID;
            this.item.StatName = this.statColumn2[index].StatName
            this.getQualityDecisionAnalysis()
            this.initAvgFigure()
            this.showPickerPStatID = false;
        },
        getQualityCheckRecord() {
            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/QualityCheckRecord/GetPageList?pageSize=${this.pageQC.pageSize}&pageIndex=${this.pageQC.pageNum}
            &PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}&MaterialID=${this.item.MaterailID}`
            ).then(resp => {
                //  alert(JSON.stringify(resp))
                if (resp.HttpCode === "200" && resp.Data.length > 0) {
                    this.dataQC = resp.Data
                    this.pageQC.total = resp.Total
                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })
        },
        qc_page() {
            this.getQualityCheckRecord()
        },

        getQualityDecision() {

            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/QualityDecisionSupport/GetList?PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}`
            ).then(resp => {

                if (resp.HttpCode === "200" && resp.Data.length > 0) {
                    this.currentBatch = resp.Data[0].CurrentBatch
                    this.libStrict = resp.Data[0].AddLabName
                    this.appearanceStrict = resp.Data[0].AddApprenName
                    this.allErrorNum = resp.Data[0].TotalAbnormal
                    this.libErrorNum = resp.Data[0].LabAbnormalCount
                    this.apErrorNum = resp.Data[0].ApprenAbnormalCount
                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })
        },
        getQualityAppearanceCheck() {
            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/QualityAppearanceCheck/GetPageList?pageSize=${this.sysPage.pageSize}&pageIndex=${this.sysPage.pageNum}
            &PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}&MaterialID=${this.item.MaterailID}`
            ).then(resp => {
                //  alert(JSON.stringify(resp))
                if (resp.HttpCode === "200") {
                    this.dataSYS = resp.Data

                    this.sysPage.total = resp.Total
                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })
        },
        sys_page() {
            // alert(this.sysPage.pageNum)
            this.getQualityAppearanceCheck()
        },
        getQualityDecisionAnalysis() {
            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/QualityDecisionAnalysis/GetPageList?pageSize=${this.pageDA.pageSize}&pageIndex=${this.pageDA.pageNum}
            &PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}&MaterialID=${this.item.MaterailID}&StatID=${this.item.StatID}`
            ).then(resp => {

                if (resp.HttpCode === "200") {
                    this.dataDA = resp.Data
                    this.pageDA.total = resp.Total
                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })
        },
        da_page() {
            // alert(this.sysPage.pageNum)
            this.getQualityDecisionAnalysis()
        },
        rowClick(rowIndex, columnName, rowData) {
            api.openWin({
                name: 'checkAppreance',
                url: './qAssistance-checkAppreance.html',
                pageParam: {
                    item: this.dataSYS[rowIndex]
                }
            });

        },
        rowClick02(rowIndex, columnName, rowData) {

            let data = this.dataDA[rowIndex]

            // alert(_httpClientApisie.getApiPrefix()+`/QualityCheckRecord/GetList?PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}&BatchID=${data.BatchID}`)
            // alert(data.BatchID)
            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/QualityCheckRecord/GetList?PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}&BatchID=${data.BatchID}`
            ).then(resp => {

                // alert(JSON.stringify(resp))
                if (resp.HttpCode === "200") {
                    //BatchId 不起作用

                    let index = 0;
                    if (resp.Data.length > 0) {

                        for (let i = 0; i < resp.Data.length; i++) {
                            let item = resp.Data[i]
                            if (item.BatchID == data.BatchID) {
                                index = i;
                                break;
                            }
                        }

                        let a = resp.Data[index]

                        // alert(a.SheetID)
                        this.getSheetInfo(a.Id, a.SheetID)
                    } else {
                        alert("未查询到相关数据1")
                    }


                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })


        },
        getSheetInfo(pid, sheetID) {
            // alert(_httpClientApisie.getApiPrefix()+`/FixedSheetItem/GetList?SheetID=${sheetID}&ItemValueInputType=${this.item.StatID}&SheetItemName=${this.item.StatName}`)
            var StatName = "";
            //alert(this.item.StatID);
            if (this.item.StatID == "ST02") {
                StatName = "%E5%AE%B9%E9%87%8F";
            }
            else {
                StatName = this.item.StatName;
            }
            //alert(StatName);
            //alert(_httpClientApisie.getApiPrefix() + `/FixedSheetItem/GetList?SheetID=${sheetID}&ItemValueInputType=${this.item.StatID}&SheetItemName=${StatName}`)
            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/FixedSheetItem/GetList?SheetID=${sheetID}&ItemValueInputType=${this.item.StatID}&SheetItemName=${StatName}`
            ).then(resp => {

                //alert(JSON.stringify(resp))
                if (resp.HttpCode === "200") {

                    if (resp.Data.length > 0) {
                        let a = resp.Data[0];

                        let rows = a.PositionRow;
                        let col = a.PositionCol;

                        // alert(JSON.stringify(a))
                        this.getQualityCheckRecordItem(pid, rows, col)
                    } else {
                        alert("未查询到相关数据2")
                    }


                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })

        },

        getQualityCheckRecordItem(pid, rows, col) {

            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() +
                "/QualityCheckRecordItem/GetListJsonByParentId?ColIndex=" +
                col +
                "&ParentId=" + pid
            ).then(resp => {
                // alert(JSON.stringify(resp))
                if (resp.HttpCode === "200") {


                    if (resp.Total == 0) {
                        alert("未查询到相关数据3");
                    } else {
                        let QualityCheckRecordItemList = resp.Data;

                        for (let i = 0; i < QualityCheckRecordItemList.length; i++) {
                            let item = QualityCheckRecordItemList[i]
                            this.RecordValueList.push(item.RecordValue);
                        }


                        let s = this.RecordValueList
                        api.openWin({
                            name: 'checkAppreance',
                            url: './quality-laboratoryTestDataItem01.html',
                            pageParam: {
                                RecordValueList: s
                            }
                        });
                        this.RecordValueList = []

                    }



                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })

        },
        getGetCurrentShiftTreeTypeMsg() {
            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/RealtimeEventMessage/GetCurrentShiftTreeTypeMsg?pageSize=${this.bbcPage.pageSize}&pageIndex=${this.bbcPage.pageNum}
            &PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}&StatID=${this.item.StatID}`
            ).then(resp => {
                //  alert(JSON.stringify(resp))
                if (resp.HttpCode === "200") {

                    for (let i = 0; i < resp.Data.length; i++) {
                        let value = resp.Data[i].EventTypeID;
                        if (value == 'CA') {
                            resp.Data[i].EventType = "生产条件异常";
                        }
                        else if (value == 'TFC' || value == 'TFB' || value == 'TFC') {
                            resp.Data[i].EventType = "生产工艺异常";
                        }
                        else { resp.Data[i].EventType = "机器设备异常"; }


                        resp.Data[i].processStatus = resp.Data[i].Closed == true ? "已完成" : "未完成";
                    }

                    this.dataBBC = resp.Data

                    this.bbcPage.total = resp.Total
                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })
        },
        bbc_page() {
            this.getGetCurrentShiftTreeTypeMsg()
        },

        initAvgFigure() {

            _httpClientApisie.get(
                _httpClientApisie.getApiPrefix() + `/QualityDecisionAnalysis/GetList?PLineID=${this.item.PlineId}&POrderID=${this.item.POrderID}&MaterialID=${this.item.MaterailID}&StatID=${this.item.StatID}`
            ).then(resp => {

                if (resp.HttpCode === "200") {
                    let a = []
                    let b = []
                    let c = []
                    let d = []
                    for (let i = 0; i < resp.Data.length; i++) {
                        let item = resp.Data[i]

                        if (!a.includes(item.BatchID)) {
                            a.push(item.BatchID)
                            b.push(item.AverageValue)
                        }

                        if (!c.includes(item.StandardGap)) {
                            c.push(item.BatchID)
                            d.push(item.StandardGap)
                        }
                    }

                    setTimeout(() => {

                        this.render01(a, b)
                        this.render02(c, d)

                        //todo
                        this.render03(a, b, c)
                        this.render04(a, b)
                    }, 500)


                }

            }).catch(err => {
                alert(JSON.stringify(err))
            })


        },

        render01(a, b) {

            var myChart = echarts.init(this.$refs.avg);


            var option;
            option = {
                xAxis: {
                    type: 'category',
                    data: a
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: b,
                        type: 'line'
                    }
                ]
            };

            option && myChart.setOption(option);
        },

        render02(a, b) {

            var myChart = echarts.init(this.$refs.sd);

            var option;
            option = {
                xAxis: {
                    type: 'category',
                    data: a
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: b,
                        type: 'line'
                    }
                ]
            };

            option && myChart.setOption(option);
        },

        render03(a, b, c) {
            var myChart = echarts.init(this.$refs.wsd);
            var option;

            option = {

                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['最高温度', '最低温度']
                },


                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },

                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '最低温度',
                        type: 'line',
                        stack: 'Total',
                        data: [120, 132, 101, 134, 90, 230, 210]
                    },
                    {
                        name: '最高温度',
                        type: 'line',
                        stack: 'Total',
                        data: [220, 182, 191, 234, 290, 330, 310]
                    },

                ]
            };

            option && myChart.setOption(option);

        },
        render04(a, b) {
            var myChart = echarts.init(this.$refs.mbh);
            var option;

            option = {
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['蒸发量', '降水量']
                },

                calculable: true,
                xAxis: [
                    {
                        type: 'category',
                        // prettier-ignore
                        data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '蒸发量',
                        type: 'bar',
                        data: [
                            2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
                        ],
                        markPoint: {
                            data: [
                                { type: 'max', name: 'Max' },
                                { type: 'min', name: 'Min' }
                            ]
                        },
                        markLine: {
                            data: [{ type: 'average', name: 'Avg' }]
                        }
                    },
                    {
                        name: '降水量',
                        type: 'bar',
                        data: [
                            2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
                        ],
                        markPoint: {
                            data: [
                                { name: 'Max', value: 182.2, xAxis: 7, yAxis: 183 },
                                { name: 'Min', value: 2.3, xAxis: 11, yAxis: 3 }
                            ]
                        },
                        markLine: {
                            data: [{ type: 'average', name: 'Avg' }]
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }



    },
};
</script>

<style  scoped>
.selectdTextScroll {
    display: inline-block;
    /* position: fixed; */
    top: 9rem;
    overflow: scroll;
    right: 0;
    width: 100%;
    height: 80%;
    z-index: 1;
}
</style>